home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DLLCust_Files / PREPOST / SCALE.C < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.6 KB  |  46 lines

  1. // Dynamic link library implementation of a generic pre/post-processor
  2.  
  3. #include "NSDLL.h" 
  4.  
  5. /***************************/
  6. /* Activation of component */
  7. __declspec(dllexport) BOOL performPrePost(
  8.     DLLData    *instance,    // Pointer to instance data (may be NULL)
  9.     NSFloat    *input,     // Pointer to the input data
  10.     NSFloat    *output,     // Pointer to the output data
  11.     int rows,         // Number of rows of data
  12.     int cols,         // Number of cols of data
  13.     BOOL preprocessor    // Flag to indicate whether this is a preprocessor or postprocessor
  14.     )
  15. {
  16.     int i, length=rows*cols;
  17.     float gain = getFloatParameter(instance, 2, 1);
  18.     float offset = getFloatParameter(instance, 3, 1);
  19.  
  20.     for (i=0; i<length; i++)
  21.         output[i] = gain*(input[i] + offset);
  22.     return TRUE;
  23. }
  24.  
  25. /******************************************/
  26. /* Management of instance data (OPTIONAL) */
  27. __declspec(dllexport) DLLData *allocPrePost(
  28.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  29.     int *rows,         // Number of rows of output data, can be changed to reflect a diffenent number for the input data
  30.     int *cols,         // Number of cols of output data, can be changed to reflect a diffenent number for the input data
  31.     BOOL preprocessor    // Flag to indicate whether this is a preprocessor or postprocessor
  32.     )
  33. {
  34.     DLLData *instance = allocDLLInstance(oldInstance);
  35.     setParameterName(instance, 2, 1, "Gain", FALSE);
  36.     setFloatParameter(instance, 2, 1, 1.0f, FALSE);
  37.     setParameterName(instance, 3, 1, "Offset", FALSE);
  38.     setFloatParameter(instance, 3, 1, 0.0f, FALSE);
  39.     return instance;
  40. }
  41.  
  42. __declspec(dllexport) void freePrePost(DLLData *instance)
  43. {
  44.     freeDLLInstance(instance); 
  45. }
  46.